package com.home.moon.chat.controller;

import com.home.moon.chat.model.Chats;
import com.home.moon.chat.model.Users;
import com.home.moon.chat.service.impl.ChatServiceImpl;
import com.home.moon.util.UnionResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author auto
 */
@Api(tags = "聊天")
@Controller
@RequestMapping("/chat")
public class ChatController {
    @Autowired
    private ChatServiceImpl chatService;

    @ApiOperation("聊天")
    @PostMapping("/chat")
    @ResponseBody
    public UnionResult chat(@RequestBody Chats chat){
        return UnionResult.OK(chatService.addChat(chat));
    }

    @ApiOperation("查询聊天列表")
    @PostMapping("/getChats")
    @ResponseBody
    public UnionResult getChats(@RequestBody Users user){
        return UnionResult.OK(chatService.getChats(user));
    }
}
